package com.java110.mall.cart.bmo.housekeepingServUser.impl;

import com.java110.mall.cart.bmo.housekeepingServUser.IGetHousekeepingServUserBMO;
import com.java110.intf.cart.IHousekeepingServUserInnerServiceSMO;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import com.java110.dto.housekeeping.HousekeepingServUserDto;

import java.util.ArrayList;
import java.util.List;

@Service("getHousekeepingServUserBMOImpl")
public class GetHousekeepingServUserBMOImpl implements IGetHousekeepingServUserBMO {

    @Autowired
    private IHousekeepingServUserInnerServiceSMO housekeepingServUserInnerServiceSMOImpl;

    /**
     *
     *
     * @param  housekeepingServUserDto
     * @return 订单服务能够接受的报文
     */
    public ResponseEntity<String> get(HousekeepingServUserDto housekeepingServUserDto) {


        int count = housekeepingServUserInnerServiceSMOImpl.queryHousekeepingServUsersCount(housekeepingServUserDto);

        List<HousekeepingServUserDto> housekeepingServUserDtos = null;
        if (count > 0) {
            housekeepingServUserDtos = housekeepingServUserInnerServiceSMOImpl.queryHousekeepingServUsers(housekeepingServUserDto);
        } else {
            housekeepingServUserDtos = new ArrayList<>();
        }

        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) housekeepingServUserDto.getRow()), count, housekeepingServUserDtos);

        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);

        return responseEntity;
    }

}
